package com.github.kotvertolet.youtubejextractor.models.newModels;

import com.google.gson.annotations.SerializedName;
import ohos.utils.Parcel;
import ohos.utils.Sequenceable;

import java.io.Serializable;

/**
 * 类功能描述(类上)
 *
 * @author AnBetter
 * @since 2021-04-15
 */
public class AudioConfig implements Sequenceable, Serializable {
    @SerializedName("perceptualLoudnessDb")
    private float perceptualLoudnessDb;

    @SerializedName("loudnessDb")
    private float loudnessDb;

    @SerializedName("enablePerFormatLoudness")
    private boolean isEnablePerFormatLoudness;

    public static final Sequenceable.Producer<AudioConfig> CREATOR = new Producer<AudioConfig>() {
        @Override
        public AudioConfig createFromParcel(Parcel parcel) {
            // Initialize an instance first, then do customized unmarshlling.
            AudioConfig audioConfig = new AudioConfig();
            audioConfig.unmarshalling(parcel);
            return audioConfig;
        }
    };


    @Override
    public boolean marshalling(Parcel parcel) {
        parcel.writeFloat(this.perceptualLoudnessDb);
        parcel.writeFloat(this.loudnessDb);
        parcel.writeBoolean(this.isEnablePerFormatLoudness);
        return true;
    }

    @Override
    public boolean unmarshalling(Parcel parcel) {
        this.perceptualLoudnessDb=parcel.readFloat();
        this.loudnessDb=parcel.readFloat();
        this.isEnablePerFormatLoudness=parcel.readBoolean();
        return true;
    }

    @Override
    public String toString() {
        return "AudioConfig{" +
                "perceptualLoudnessDb = '" + perceptualLoudnessDb + '\'' +
                ",loudnessDb = '" + loudnessDb + '\'' +
                ",enablePerFormatLoudness = '" + isEnablePerFormatLoudness + '\'' +
                "}";
    }

    public float getPerceptualLoudnessDb() {
        return perceptualLoudnessDb;
    }

    public void setPerceptualLoudnessDb(float perceptualLoudnessDb) {
        this.perceptualLoudnessDb = perceptualLoudnessDb;
    }

    public float getLoudnessDb() {
        return loudnessDb;
    }

    public void setLoudnessDb(float loudnessDb) {
        this.loudnessDb = loudnessDb;
    }

    public boolean isEnablePerFormatLoudness() {
        return isEnablePerFormatLoudness;
    }

    public void setEnablePerFormatLoudness(boolean enablePerFormatLoudness) {
        isEnablePerFormatLoudness = enablePerFormatLoudness;
    }
}
